﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Services;
using OA.Bll;

namespace OA.Web.Handler
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class AjaxComboboxData : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/javascript";
            context.Response.ContentEncoding = Encoding.UTF8;
            string typeId = context.Request.QueryString["typeId"];
            string parentId = context.Request.QueryString["parentId"];
            string str;
            if (string.IsNullOrEmpty(typeId))
            {
                str = new DictionaryTypePresenter().GetDictionaryTypeInfoAll();
            }
            else
            {
                DictionaryInfoPresenter dip = new DictionaryInfoPresenter();
                if (string.IsNullOrEmpty(parentId))
                    str = dip.GetDictionaryInfoAll(Convert.ToInt32(typeId), false);
                else
                    str = dip.GetDictionaryInfoAll(Convert.ToInt32(typeId), Convert.ToInt32(parentId));

                //int id,parentid;
                //bool b = int.TryParse(typeId, out id);
                //str = b ? new DictionaryInfoPresenter().GetDictionaryInfoAll(id,false) : "{ \"flag\":\"false\",\"msg\":\"系统获取数据错误,请刷新页面(F5)后重试!\"}";

            }
            context.Response.Write(str);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
